<?php include "../public/header.php"?>
<?php include '../public/header_index.php' ?>
<style>
    .layui-table-fixed-l .layui-table-header{width: 42px;}
    div[lay-id="datalist"] .layui-table-cell{
        height:auto !important;
    };
</style>
<body>
    <div class="layui-fluid layui-fluid_list">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body">
                        <div id="datalist" lay-filter="datalist"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

<script type="text/html" id="operation">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="change" style="height: 26px;line-height: 26px;">更换</a>
</script>

<script type="text/javascript">
    // 查询条件
    var list = parent.set_list();

    layui.use(['form','element','table','laytp'],function() {
        var form = layui.form;
        var table = layui.table;
        var laytp = layui.laytp;

        table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_cert_matching_change)
            ,where: {list:list,is_both:1}, page: false, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: false, overflow: TabInit.overflow
            ,defaultToolbar: false,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response
            ,text: TabInit.text
            ,parseData: function(res){
                return {
                    "code": res.code,
                    "msg": res.message,
                    "data": res.data.data
                };
            }
            ,cols: [[
                {type: 'numbers', title: '序号',fixed:'left'}
                ,{field: 'person_name', title: '持证人',event:'person_name',templet:function (e) {
                    return '<a class="colorlan">'+e.person_name+'</a>';
                }}
                ,{field: 'nature', title: '人员性质'}
                ,{field: 'cert_name', title: '证书名称',event:'cert_name',templet:function (e) {
                    return '<a class="colorlan">'+e.cert_name+'</a>';
                }}
                ,{field: 'number', title: '证书编号'}
                ,{field: 'major', title: '证书专业'}
                ,{field: 'expiry_dt', title: '有效期'}
                ,{field: 'issue_unit', title: '发证单位'}
                ,{field: 'chanid_name', title: '归属公司'}
                ,{field: 'goes', title: '证书去向'}
                ,{field: 'status', title: '证书状态'}
                ,{field: 'state', title: '人员状态'}
                ,{field: 'social', title: '社保状态'}
                ,{title: '操作',templet: '#operation', fixed: 'right',width:120}
            ]]
            , done: function (res) {
                // 处理列表fixed的高度问题
                $('div[lay-id="datalist"] .layui-table-main>table>tbody>tr').each(function (i) {
                    var height = $(this).height();
                    $('div[lay-id="datalist"] .layui-table-fixed-l>.layui-table-body>table>tbody>tr')
                        .eq(i).css('cssText','height:'+height+'px !important');
                    $('div[lay-id="datalist"] .layui-table-fixed-r>.layui-table-body>table>tbody>tr')
                        .eq(i).css('cssText','height:'+height+'px !important');
                });
            }
        });

        // 详情
        table.on('tool(datalist)',function (obj) {
            var data = obj.data;
            if(obj.event === 'cert_name'){
                open_page('../cert/show.php?id='+data.id,'证书详情');
            }else if (obj.event === 'cert_status'){
                open_page('../cert/engin_build.php?id='+data.id,'在用项目');
            }
        });

        //监听工具条
        table.on('tool(datalist)', function(obj){
            var data = obj.data;
            if(obj.event === 'change'){
                // 传值到父页面 并关闭弹窗
                $('#change',parent.document).val(JSON.stringify(data));
                parent.layer.closeAll();
            }
        });
    });
</script>
</html>















